﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class BaseInfoService : IBaseInfoService
    {
        public string Delete(List<string> IDS, string className, PubParasInfo pubParasInfo)
        {
            try
            {
                string result = BaseInfoFactory.CreateInstance(className, pubParasInfo).Delete(IDS);
                new OperationLogBLL().Insert("BaseInfoService_Delete", IDS, className, pubParasInfo);
                return result;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return "";
        }

        public DataSet GetAllInfo(string className, PubParasInfo pubParasInfo)
        {
            try
            {
                return BaseInfoFactory.CreateInstance(className, pubParasInfo).GetAllInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return null;
        }

        public object GetInfoByID(string id, string className, PubParasInfo pubParasInfo)
        {
            try
            {
                return BaseInfoFactory.CreateInstance(className, pubParasInfo).GetInfoByID(id);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return null;
        }

        public DataSet GetInfoByQueryEntity(object obj, string className, PubParasInfo pubParasInfo)
        {
            try
            {
                return BaseInfoFactory.CreateInstance(className, pubParasInfo).GetInfoByQueryEntity(obj);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return null;
        }

        public string Insert(object obj, string className, PubParasInfo pubParasInfo)
        {
            try
            {
                string result = BaseInfoFactory.CreateInstance(className, pubParasInfo).Insert(obj);
                new OperationLogBLL().Insert("BaseInfoService_Insert", obj, className, pubParasInfo);
                return result;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return "";
        }

        public string Update(object obj, string className, PubParasInfo pubParasInfo)
        {
            try
            {
                string result = BaseInfoFactory.CreateInstance(className, pubParasInfo).Update(obj);
                new OperationLogBLL().Insert("BaseInfoService_Update", obj, className, pubParasInfo);
                return result;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "BaseInfoService异常");
            }
            return "";
        }
    }
}

